<?php
/**
 * Created by PhpStorm.
 * User: yu
 * Date: 18-12-28
 * Time: 上午10:47
 * 异常基类
 */

namespace app\components\exceptions;

use Throwable;
use yii\helpers\ArrayHelper;

class Exception extends \Exception
{
    public function __construct($code = 0, $message = "", Throwable $previous = null)
    {
        parent::__construct($message, $code, $previous);
    }

    /**
     * 错误代码库
     *
     * @var mixed
     * msg 定义原始的错误信息
     */
    public static $exceptionCode;


    /**
     * 获得错误处理信息
     *
     * @param mixed $key
     */
    public function getMsg($key='msg')
    {
        if($this->getMessage()) return $this->getMessage();

        return ArrayHelper::getValue(static::$exceptionCode, $this->code . '.'.$key);
    }



}